package com.sunchangpeng.client.nio;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.nio.channels.Selector;

public class Dispatcher {
    private static final Logger LOGGER = LoggerFactory.getLogger(Dispatcher.class);

    private Selector selector;

    public void start(String host, int port) {
        try {
            selector = Selector.open();
            LOGGER.info("dispatcher start in port:{}", port);
        } catch (IOException e) {
            LOGGER.error("", e);
            if (selector != null) {
                try {
                    selector.close();
                } catch (IOException ex) {
                    LOGGER.error("", ex);
                }
            }
        }
    }
}
